/*
 * =====================================================================================
 *
 *       Filename:  kernelmod.c
 *
 *    Description:  Simple Kernel Module. Moar to do. Writes number of jiffies to /proc filesystem
 *
 *        Version:  1.0
 *        Created:  12.12.2011 03:03:37
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Michał Mieczkowski (mhl), 
 *        Company:  
 *
 * =====================================================================================
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/proc_fs.h>

#define PROCFS_NAME "jiffies_count"

struct proc_dir_entry *proc_file; 				//struktura pliku w /proc
//TODO: ta funkcja
int procfile_read(char *buffer, char **buffer_location, off_t offset, int buf_len, int *eof, void *data)
{
	return 0;
}

int init_module()						//tworzymy /proc
{
	proc_file= create_proc_entry(PROCFS_NAME, 0664, NULL);
	if(proc_file== NULL)
	{
		printk(KERN_ALERT "Failed to make procfile!\n");
		return -1;
	}
	//zaludnianie struktury...
	proc_file->read_proc	= procfile_read;
	proc_file->mode		= S_IFREG | S_IRUGO;			//??
	proc_file->uid		= 0;
	proc_file->gid		= 0;
	proc_file->size=	 37; 					//??	
	
	printk(KERN_INFO "/proc/%s successfully created", PROCFS_NAME);
	return 0;
	
}

void cleanup_module()
{
	remove_proc_entry(PROCFS_NAME, NULL);
	printk(KERN_INFO "Removed /proc file\n"	);
}

